package br.ucb.cm.main.ai.bean;

import java.util.List;
import java.util.Map;

import br.ucb.cm.board.bean.Location;
import br.ucb.cm.board.bean.Move;
import br.ucb.cm.config.bean.PieceConfig;

public class MoveTreeNode {
	private Move move;
	private List<MoveTreeNode> filhos;
	private MoveTreeNode pai;
	private Map<Location, PieceConfig> pieceMap;
	
	public MoveTreeNode(Move move, List<MoveTreeNode> filhos, MoveTreeNode pai) {
		this.move = move;
		this.filhos = filhos;
		this.pai = pai;
	}
	
	public void add(MoveTreeNode moveTreeNode){
		moveTreeNode.setPai(this);
		getFilhos().add(moveTreeNode);
	}

	public List<MoveTreeNode> getFilhos() {
		return filhos;
	}

	public void setFilhos(List<MoveTreeNode> filhos) {
		this.filhos = filhos;
	}

	public int getValueFuncion(){
		PieceConfig piece;
		
		if((piece = getPieceMap().get(move.getDestination()))!= null)
			return piece.getPoints().intValue(); 
		return 0;
	}
	
	public Move getMove() {
		return move;
	}

	public void setMove(Move move) {
		this.move = move;
	}

	public MoveTreeNode getPai() {
		return pai;
	}

	public void setPai(MoveTreeNode pai) {
		this.pai = pai;
	}

	public Map<Location, PieceConfig> getPieceMap() {
		return pieceMap;
	}

	public void setPieceMap(Map<Location, PieceConfig> pieceMap) {
		this.pieceMap = pieceMap;
	}

}
